<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input id="i1" type="text" value="请输入内容" onfocus="f1();"onblur="f2();">
    <script>
        function f1() {
          var  t=document.getElementById("i1");
          var val=t.value
            if (val=="请输入内容"){t.value=""}
        }
         function f2() {
          var t=document.getElementById("i1");
          var val=t.value;
          // 去空格，看字符长度
            if (val.trim().length==0){t.value="请输入内容"}
        }
    </script>
</body>
</html>